
__app.define("home_VM_Extend.js", function () {
  var home_VM_Extend = {
    agentVueMounted: function (opt) {
      opt.vm.formatProducts = () => {
        if(opt.vm.allProduct.length != 0) {
          // opt.vm.allProduct[0].fSalePrice = 111
          editPrice(opt.vm.allProduct)
        }
      };
      function editPrice(data) { 
        let obj = {
          customer: window.__app.mainV.$store.getters.currentUser.agentId,
          deliveryMethod: '自提',
          receiveAddress: '',
          productDetail: [],
        }
        data.forEach(element => {
          let product = {
            productCode: element.cCode,
            productId: element.id,
            org: element.saleOrgId,
            priceQty: 1,
            productUnitId: element.mainUnit.id,
            currency: '1655486829428736015',
            stockId: ''
          }
          obj.productDetail.push(product)
        });
        const url = 'https://saas.hlhs-bip.com/iuap-api-gateway/ajxbewdh/AcquisitionPrice/GetPriceAndFreight/pricing/acquisitionPrice?appKey=a4dc65b0fbab4f68a56e8054999a2ab3'
        __app.ajax({
          type: "POST",
          data: obj,
          url: url,
          success: (res) => {
            opt.vm.allProduct.forEach((item) => {
              item.fSalePrice = res[item.id].price
            })
            // debugger
          },
          error: function (error) {
            debugger
          }
        })
      }
    },
  };
  return home_VM_Extend;
});